﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    /*protected void Page_Load(object sender, EventArgs e)
    {
        DataClassesDataContext db = new DataClassesDataContext();
        var userQ = from s in db.studentinfo select s;
        gvStudent.DataSource = userQ;
        gvStudent.DataBind();
    }*/
    protected void Page_Load(object sender, EventArgs e)
    {
        gvBind();
    }
    protected void gvBind()
    {
        DataClassesDataContext db = new DataClassesDataContext();
        var user = from s in db.studentinfo select s;
        gvStudent.DataSource = user;
        gvStudent.DataBind();
    }
     
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        DataClassesDataContext db = new DataClassesDataContext();
        studentinfo stu = new studentinfo();
        stu.SNO = Convert.ToInt32(txtSno.Text.Trim());
        stu.SNAME = txtName.Text;
        stu.GENDER = txtGender.Text;
        stu.BIRTHDAY = Convert.ToDateTime(txtBirthday.Text);
        stu.DEPTNAME = txtDept.Text;
        db.studentinfo.InsertOnSubmit(stu);
        db.SubmitChanges();
        gvBind();
    }
}